<script language="javascript" type="text/javascript">
    $(window).scroll(
    function()
    {
        scrollTop = $(window).scrollTop();
        docHeight = getDocHeight();
        winHeight = getWinHeight();
        scrolltop20 = Math.round((getDocHeight() - getWinHeight())*0.9);
        result = getDocHeight() - getWinHeight();
		
        console.log('Top Scroll: '+ scrollTop +' || Win Height: '+ winHeight +' || Doc Height: '+ docHeight+' || scrolltop20: '+scrolltop20+' || result :'+ result );
	
        if($(window).scrollTop() >= scrolltop20)
        {
            if(killScroll == false) 
            {
                killScroll = true;
				
                $('#loading').show();
                $('#loadding-text').show();			
                $('#loading').html('<img src="images/loading.gif" alt="" width="150" height="13" />');

                if($("li:last").data('ctype') == 'webboard')
                {
                    lastPostFunc('webboard');
                }
                setTimeout(function(){killScroll = false},500);	
            }
        }
    }
); 

    function searchWebboard()
    {
        //alert('word : '+$('#product_search').val()+' -> '+'product_status : '+$('#product_status').val()+' category : '+$('#category').val()+'trade : '+ $('#trade').val()+'province : '+$('#province').val() );
		
        if($('#webboard_search').val() != '')
        {	
            $('#fromSearchwebboard').submit();
        }
        else
        {
            $('#webboardAlert').popup('open');
            setTimeout(function(){$('#webboardAlert').popup('close'); $('#webboard_search').focus()},1000);
        }
    }

</script>
<!-- Start of Modify page -->
<div data-role="page" id="modify">
    <div data-role="header">

        <h1>เว็บบอร์ด</h1>
        <a rel="external" id="link_web" href="?q=home" data-icon="back" data-iconpos="right">กลับ</a> 
        <a id="link_modify" href="#from_webboardSearch" data-icon="search" data-iconpos="right" data-transition="slidedown" data-rel="dialog">ค้นหา</a>       
    </div><!-- /header -->

    <div data-role="content">	

        <ul data-role="listview">
            <li data-role="list-divider" id="listDivider_step">
                <a rel="external" href="?q=home">หน้าแรก</a>&nbsp;&nbsp;>>&nbsp;&nbsp;<a rel="external" href="?q=webboard">เว็บบอร์ด</a>
            </li>
            <?php
            $res = $db->select_query('SELECT * FROM webboard ORDER BY id DESC LIMIT 20');
            while($arr = $db->fetch($res))
            {
                $countReply = $db->num_rows('webboard_reply', 'reply_id', 'post_id = ' . $arr['id'] . '');
                ?>
                <li data-ctype="webboard" id="webboard_<?php echo $arr['id']; ?>" last_id="<?php echo $arr['id']; ?>">
                    <a rel="external" href="?q=webboardDetail&wId=<?php echo $arr['id']; ?>">
                        <img src="<?php echo $arr['tn_part']; ?>"/>
                        <h2><?php echo $arr['post_title']; ?></h2>
                        <p><?php echo 'โดบ : ' . $arr['cr_by'] . ' วันที่ : ' . $arr['cr_date']; ?></p>
                        <span class="ui-li-count ui-btn-up-c ui-btn-corner-all"><?php echo $countReply; ?></span>
                    </a> 
                </li>
                <?php
            }
            ?>
        </ul> 
        <div id="loadding-text" style="clear:both;">&nbsp;&nbsp;</div>       
        <div id="loading" align="center"><img src="images/loading.gif" alt="" width="150" height="13" /></div>       
    </div><!-- /content -->

    <div data-role="footer" >
        <h4>Version 1.0 Beta</h4>
        <a id="link_web" href="http://www.mocyc.com" data-icon="refresh" data-iconpos="right" class="ui-btn-right">แบบปกติ</a>

    </div><!-- /footer -->
</div><!-- /page -->


<!-- From from_modifySearch -->
<div data-role="page" id="from_webboardSearch">
    <div data-role="header">
        <h1>ค้นหา</h1>
    </div>
    <div data-role="content">
        <form id="fromSearchwebboard" name="fromSearchwebboard" method="get" data-ajax="false">
            <input name="q" type="hidden" value="webboardSearch" />
            คำค้นหา
            <input  type="search" name="webboard_search" id="webboard_search" value=""  />    
            หมวดหมู่
            <select name="webboard_type" id="webboard_type">
                <option value="0" selected="selected">- ไม่ระบุ -</option>
                <option value="1">มอไซค์ คาเฟ่</option>
                <option value="2">ปัญหาเรื่องการใช้งานรถ</option>
            </select>     

            <label>&nbsp;</label><br /> 
            <input id="search" name="search" type="button" value="ค้นหา" onclick="searchWebboard();" />
        </form>

        <div data-role="popup" id="webboardAlert">
            <p>กรุณาระบุ "คำค้นหา" ที่ต้องการ<p>
        </div> 

    </div>
</div>
<!-- End From from_modifySearch -->